package cn.lovemmd.model.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 下载日志实体类
 * 
 * @author TLS
 * @since 2024-01-01
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@TableName("model_download_log")
public class DownloadLog implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 主键ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 模型ID
     */
    @TableField("model_id")
    private Long modelId;

    /**
     * 用户ID
     */
    @TableField("user_id")
    private Long userId;

    /**
     * IP地址
     */
    @TableField("ip")
    private String ip;

    /**
     * 用户代理
     */
    @TableField("user_agent")
    private String userAgent;

    /**
     * 来源页面
     */
    @TableField("referer")
    private String referer;

    /**
     * 创建时间
     */
    @TableField(value = "created_at", fill = FieldFill.INSERT)
    private LocalDateTime createdAt;

    // Getter and Setter methods
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getModelId() {
        return modelId;
    }

    public void setModelId(Long modelId) {
        this.modelId = modelId;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public String getUserAgent() {
        return userAgent;
    }

    public void setUserAgent(String userAgent) {
        this.userAgent = userAgent;
    }

    public String getReferer() {
        return referer;
    }

    public void setReferer(String referer) {
        this.referer = referer;
    }

    public LocalDateTime getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(LocalDateTime createdAt) {
        this.createdAt = createdAt;
    }

    // Builder pattern methods
    public static DownloadLogBuilder builder() {
        return new DownloadLogBuilder();
    }

    public static class DownloadLogBuilder {
        private Long id;
        private Long modelId;
        private Long userId;
        private String ip;
        private String userAgent;
        private String referer;
        private LocalDateTime createdAt;

        public DownloadLogBuilder id(Long id) {
            this.id = id;
            return this;
        }

        public DownloadLogBuilder modelId(Long modelId) {
            this.modelId = modelId;
            return this;
        }

        public DownloadLogBuilder userId(Long userId) {
            this.userId = userId;
            return this;
        }

        public DownloadLogBuilder ip(String ip) {
            this.ip = ip;
            return this;
        }

        public DownloadLogBuilder userAgent(String userAgent) {
            this.userAgent = userAgent;
            return this;
        }

        public DownloadLogBuilder referer(String referer) {
            this.referer = referer;
            return this;
        }

        public DownloadLogBuilder createdAt(LocalDateTime createdAt) {
            this.createdAt = createdAt;
            return this;
        }

        public DownloadLog build() {
            DownloadLog downloadLog = new DownloadLog();
            downloadLog.setId(this.id);
            downloadLog.setModelId(this.modelId);
            downloadLog.setUserId(this.userId);
            downloadLog.setIp(this.ip);
            downloadLog.setUserAgent(this.userAgent);
            downloadLog.setReferer(this.referer);
            downloadLog.setCreatedAt(this.createdAt);
            return downloadLog;
        }
    }
}
